/*
 * Copyright (c) 2017 Kris Occhipint.
 * http://filmsbykris.com
 *
 * This program is free software: you can redistribute it and/or modify  
 * it under the terms of the GNU General Public License as published by  
 * the Free Software Foundation, version 3.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

#include<stdio.h>
#include <time.h>

int delay(int seconds){
    //Convert seconds to milli seconds
    int milli = 1000 * seconds;
 
    // Get starttime
    clock_t start = clock();
 
    // loop untill time is reached
    while (clock() < start + milli);
}

int loop(){
  for (int i=1;i<=10;i++){
    fflush(stdout);
    printf("\rI'm counting: %d", i);
    delay(1000); 
  }
  //end with new line
  printf("\n");
  return 0;
}

int main(){
  printf("I'm going to count...\n");
  loop();
  return 0;
}